package priv.pront.code.mati.province.comp;

import java.util.Scanner;

/**
 * @Description:
 * @Author: pront
 * @Time:2023-11-18 15:40
 */
public class Main9 {

    static int n;
    static int a = 0, b = 0, c = 0;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        for (int i = 1; i <= n; i++) {
            String s = i + "";
            if((i % 3 == 0 || s.contains("3")) && (i % 5 == 0 || s.contains("5"))) {
                c++;
            }else if(i % 5 == 0 || s.contains("5")) {
                b++;
            }else if(i % 3 == 0 || s.contains("3")){
                a++;
            }

        }
        System.out.println(a);
        System.out.println(b);
        System.out.println(c);

    }
}
